package com.alit.face.koala.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alit.face.koala.bean.http.KoalaRequestData;
import com.alit.face.koala.entity.KoalaHistoryCallback;
import com.alit.face.koala.repository.KoalaHistoryCallbackRespository;

@Service
public class KoalaHistoryCallbackService {
  @Autowired
  private KoalaHistoryCallbackRespository historyKoalaCallbackRespository;

  public void saveHistory(KoalaRequestData koalaRequestData, String ip, String name, Integer genderNumber,
      boolean isSayHello) {
    KoalaHistoryCallback data = new KoalaHistoryCallback();
    data.setIp(ip);
    data.setScreenToken(koalaRequestData.getScreenToken());
    data.setTimestamp(koalaRequestData.getTimestamp());
    data.setPhotoMD5(koalaRequestData.getPhotoMd5());
    data.setAge(koalaRequestData.getAge());
    data.setGender(koalaRequestData.getGender());
    data.setQuality(koalaRequestData.getQuality());
    data.setSubjectId(koalaRequestData.getSubjectId());
    data.setName(name);
    data.setSubjectGender(genderNumber);
    data.setSayHello(isSayHello);
    historyKoalaCallbackRespository.save(data);
  }
}
